﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Base.cshtml";
}
@section head{
    <script src="@Url.Content("~/Content/roohui/jquery-validation/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/roohui/jquery-validation/jquery.metadata.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Content/roohui/jquery-validation/messages_cn.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#txtKey").ligerTextBox({ width: 300 });
            $("#guaranteeCompany").ligerComboBox(
                {
                    url: '/GuarCompany/GetGuarCompanyListByKey',
                    valueField: 'ID',
                    textField: 'CompanyName',
                    autocomplete: true,
                    width:250
                }
            );
             $("#txtKey").focus();
        });
    </script>
}
<table cellpadding="0" cellspacing="0" class="l-table-edit">
    <tr>
        <td align="right" class="l-table-edit-td">
            关键字:
        </td>
        <td align="left" class="l-table-edit-td">

            <input name="txtKey" id="txtKey" ltype="text"  ligerui="width:300"
                style="width: 300;"/>
        </td>
        <td align="left">
        </td>
        <td align="right" class="l-table-edit-td">
            担保公司:
        </td>
        <td align="left" class="l-table-edit-td">
            <input type="text" id="guaranteeCompany" />
        </td>
        <td align="left" class="l-table-edit-td">
            <input type="button" value="查询" id="btnSearch" onclick="search()" class="l-button" />
        </td>
    </tr>
</table>
<div id="projectgrid">
</div>
<script type="text/javascript">
    var projectgrid;
    $(function () {
        projectgrid = $("#projectgrid").ligerGrid({
            columns: [

                { display: '项目编码', name: 'ProjectCode', width: '10%', isSort: false },
                { display: '项目名称', name: 'ProjectTitle', width: '15%', isSort: false },
                { display: '产品名称', name: 'ProductName', width: '15%', isSort: false},
                { display: '借款企业', name: 'EnterpriseName', width: '15%', isSort: false,
                    render: function (item) {
                        return item.Enterprise.EnterpriseName;
                    }
                },
                 
                { display: '借款金额', name: 'CycleAmount', width: '12%', isSort: false,
                    render: function (item) {
                        return Number(item.Financing/10000).toFixed(2)+"万元";
                    }
                },
                { display: '借款时长', name: 'CycleAmount', width: '8%', isSort: false,
                    render: function (item) {
                        var durationType=item.Policy.DurationType==0?"天":"月";
                        return (item.CycleAmount * item.Policy.Duration) + durationType;
                    }
                },
                { display: '担保公司', name: 'CompanyName', width: '10%', isSort: false,
                    render: function (item) {
                        return item.GuaranteeCompany.CompanyName;
                    }
                },

                { display: '状态', name: 'Status', width: '8%', isSort: false,
                    render: function (item) {
                        if (parseInt(item.Status) == 1) return '已提交';
                        else if (parseInt(item.Status) == 2) return '审核中';
                    }
                },
                {
                    display: '操作', isAllowHide: false,
                    render: function (row) {

                        var html = '<a href="#" onclick="grid_project_audit(\'' + row.ID + '\')">审核</a>';

                        return html;
                    }
                }
                ],
            width: '100%', height: '100%', rownumbers: true,
            dataAction: 'server',
            url: "/ProjectAudit/GetProjectListForAudit",
            pageSizeOptions: [10],
            pageSize: 10
        });
         
    });
    function search() {
        var guaranteeCompanyID = liger.get("guaranteeCompany").getValue();
        if (guaranteeCompanyID == "") {
            guaranteeCompanyID = "-1";
        }
        projectgrid.setOptions(
             {
                 parms:
                [
                    { name: "key", value: $("#txtKey").val() },
                    { name: "guaranteeCompanyID", value: guaranteeCompanyID },
                    { name: "page", value: 1 }
                ]
             });
             projectgrid.loadData();
         }
         function grid_project_audit(projectID) {
             location.href = decodeURIComponent("/ProjectAudit/ProjectAudit?projectID=" + projectID);
         }
</script>
